<?php

echo "<Processing>\n";

wb_process();

function wb_process() {
	global $tm;

$cmd = $_POST["cmd"];
$detail = $_POST["detail"];

switch($cmd) {
case "cmd_wb_add":
	$netbios = strtolower(ltrim(rtrim($detail)));
	if(strlen($netbios) > 0) {
		// create new task on server
		$task = $tm->add();
		// set some task-specific data
		$task->set("todo", "wb_add");
		$task->set("netbios", strtolower(ltrim(rtrim($detail))));
		// start task
		$task->start();

		// trigger a few check automatically upon add
/*		wb_process("ping", $detail);
		wb_process("qwinsta", $detail);
		wb_process("sysinfo", $detail);
		wb_process("li_prod", $detail);
		wb_process("analyze", $detail);
*/	}
	break;
case "del":
	// create new task on server
	$task = $tm->add();
	// set some task-specific data
	$task->set("todo", "wb_del");
	$task->set("netbios", $detail);
	// start task
	$task->start();
	break;
case "set":
	// create new task on server
	$task = $tm->add();
	// set some task-specific data
	$task->set("todo", "wb_set");
	$task->set("netbios", $detail);
	$task->set("data", "test_dat");
	$task->set("value", "test_val");
	// start task
	$task->start();
	break;
case "sysinfo":
	// create new task on server
	$task = $tm->add();
	// set some task-specific data
	$task->set("todo", "wb_sysinfo");
	$task->set("netbios", $detail);
	// start task
	$task->start();
	break;
case "qwinsta":
	// create new task on server
	$task = $tm->add();
	// set some task-specific data
	$task->set("todo", "wb_qwinsta");
	$task->set("netbios", $detail);
	// start task
	$task->start();
	break;
case "ping":
	// create new task on server
	$task = $tm->add();
	// set some task-specific data
	$task->set("todo", "wb_ping");
	$task->set("netbios", $detail);
	// start task
	$task->start();
	break;
case "dsquery":
	$output = array();
	$cmd = "dsquery computer -name \"$detail*\"";
	exec($cmd, $output);
	echo "$cmd<br>\n";
	foreach($output as $line) {
		echo "$line<br>\n";
	}
	break;
case "li_prod":
	// create new task on server
	$task = $tm->add();
	// set some task-specific data
	$task->set("todo", "wb_li_prod");
	$task->set("netbios", $detail);
	// start task
	$task->start();
	break;
case "analyze":
	// create new task on server
	$task = $tm->add();
	// set some task-specific data
	$task->set("todo", "wb_analyze");
	$task->set("netbios", $detail);
	// start task
	$task->start();
	break;
}
}

?>
